<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:phi="http://java.sun.com/jsf/composite/pharmacy"
                xmlns:bi="http://java.sun.com/jsf/composite/bill"
                xmlns:pa="http://java.sun.com/jsf/composite/paymentMethod"
                xmlns:pat="http://java.sun.com/jsf/composite/patient">



    <ui:define name="content">


        <h:panelGroup rendered="#{!(webUserController.hasPrivilege('OpdPreBilling'))}" >
            You are NOT authorized
        </h:panelGroup>

        <h:panelGroup rendered="#{webUserController.hasPrivilege('OpdPreBilling')}" styleClass="opdPanel" >
            <h:form id="form">
                <p:focus id="focusIx" for="acIx" />
                <f:facet name="header">
                    <h:outputLabel value="OPD"/>
                </f:facet>
                <h:panelGroup rendered="#{!opdPreBillController.printPreview}" styleClass="alignTop" >
                    <p:panel style="min-height: 600px; position:relative;"  >
                        <h:panelGrid columns="20"  >
                            <h:panelGrid columns="1">                                
                                <p:selectOneMenu   id="pay" value="#{opdPreBillController.paymentMethod}">     
                                    <f:selectItems value="#{enumController.paymentMethods}"  />
                                    <p:ajax process="@this cmbPs" 
                                            update=":#{p:component('pBillDetails')}  tblBillItem creditCard cheque slip"
                                            event="change"
                                            listener="#{opdPreBillController.changeListener()}"/>
                                </p:selectOneMenu>
                            </h:panelGrid>
                            <h:panelGrid columns="1">                            
                                <p:selectOneMenu   id="cmbPs" value="#{opdPreBillController.paymentScheme}">     
                                    <f:selectItem itemLabel="Select Discount Scheme"/>
                                    <f:selectItems value="#{paymentSchemeController.paymentSchemesForOPD}" 
                                                   var="paysch" itemLabel="#{paysch.name}" itemValue="#{paysch}"  />
                                    <p:ajax process="@this pay" 
                                            update=":#{p:component('pBillDetails')} :#{p:component('creditCompany')} :#{p:component('creditStaff')}  tblBillItem creditCard cheque slip" 
                                            event="change" 
                                            listener="#{opdPreBillController.changeListener()}"/>
                                </p:selectOneMenu>
                            </h:panelGrid>
                            <p:inputText value="#{opdPreBillController.comment}" id="comment"/>
                            <p:watermark value="Comment" for="comment"/>


                            <h:panelGroup id="creditCard" style="display: #{opdPreBillController.paymentMethod ne 'Card' ? 'none' : 'block'} ; ">
                                <pa:creditCard paymentMethodData="#{opdPreBillController.paymentMethodData}"/>
                            </h:panelGroup>

                            <h:panelGroup id="cheque" style="display: #{opdPreBillController.paymentMethod ne 'Cheque' ? 'none' : 'block'} ; " >
                                <pa:cheque paymentMethodData="#{opdPreBillController.paymentMethodData}"/>
                            </h:panelGroup>

                            <h:panelGroup id="slip" style="display: #{opdPreBillController.paymentMethod ne 'Slip' ? 'none' : 'block'} ;">
                                <pa:slip paymentMethodData="#{opdPreBillController.paymentMethodData}"/>
                            </h:panelGroup>

                            <p:commandButton  value="Create Bill" action="#{opdPreBillController.settleBill}" ajax="false"  style="width: 200px; padding: 1px;border: 1px solid ; margin: auto;">
                            </p:commandButton>
                            <p:commandButton value="New Bill" ajax="false" action="#{opdPreBillController.prepareNewBill()}" >
                            </p:commandButton>
                            <p:commandButton value="Mark as Foreigner" action="#{opdPreBillController.markAsForeigner}" rendered="#{!opdPreBillController.foreigner}" ajax="false" ></p:commandButton>
                            <p:commandButton value="Mark as Local" action="#{opdPreBillController.markAsLocal}" rendered="#{opdPreBillController.foreigner}" ajax="false" ></p:commandButton>
                            <p:commandButton value="Print Last Bill" ajax="false" action="opd_bill_print_last" >
                            </p:commandButton>
                        </h:panelGrid>



                        <h:panelGrid columns="2" >

                            <h:panelGrid columns="1" >

                                <p:panel  style="background-color: grey;" >
                                    <h:panelGroup id="panelPatient" >

                                        <p:tabView id="tvPt" activeIndex="#{opdPreBillController.patientSearchTab}"  >
                                            <p:ajax event="tabChange"   process="@this"  
                                                    update=":#{p:component('cmbPs')} :#{p:component('tblBillItem')} :#{p:component('pBillDetails')} "
                                                    listener="#{opdPreBillController.onTabChange}" />

                                            <p:tab id="tabNewPt" title="New Patient"   >


                                                <table >
                                                    <tr >
                                                        <td >
                                                            <p:outputLabel value="Title &amp; Name" ></p:outputLabel>
                                                        </td>
                                                        <td> : </td>
                                                        <td >
                                                            <p:selectOneMenu  id="cmbTitle"  
                                                                              value="#{opdPreBillController.newPatient.person.title}"  >
                                                                <f:selectItem itemLabel="Select Title" />
                                                                <f:selectItems value="#{opdPreBillController.title}"/>
                                                            </p:selectOneMenu>

                                                        </td>
                                                        <td  >
                                                            <p:inputText autocomplete="off"  id="txtNewPtName" 
                                                                         value="#{opdPreBillController.newPatient.person.name}" 
                                                                         style="width: 350px;text-transform:capitalize;">
                                                            </p:inputText>
                                                        </td>
                                                    </tr>

                                                    <tr>
                                                        <td>
                                                            <p:outputLabel value="Sex &amp; Age" ></p:outputLabel>
                                                        </td>
                                                        <td> : </td>
                                                        <td>
                                                            <p:selectOneMenu id="txtNewSex"  value="#{opdPreBillController.newPatient.person.sex}" >
                                                                <f:selectItem itemLabel="Select Sex"/>
                                                                <f:selectItems value="#{opdPreBillController.sex}"/>
                                                            </p:selectOneMenu>
                                                        </td>
                                                        <td>
                                                            <h:panelGrid columns="4">
                                                                <p:inputText autocomplete="off"  id="year"  
                                                                             value="#{opdPreBillController.yearMonthDay.year}" 
                                                                             style="width: 50px; ">
                                                                    <f:ajax event="keyup" execute="@this month day" render="calNewPtDob" 

                                                                            listener="#{opdPreBillController.dateChangeListen()}"  />
                                                                </p:inputText>
                                                                <p:inputText autocomplete="off" id="month"
                                                                             style="width: 50px; " value="#{opdPreBillController.yearMonthDay.month}">
                                                                    <f:ajax event="keyup" execute="@this year day" render="calNewPtDob" listener="#{opdPreBillController.dateChangeListen()}"  />
                                                                </p:inputText>
                                                                <p:inputText autocomplete="off" id="day" 
                                                                             style="width: 50px;" value="#{opdPreBillController.yearMonthDay.day}">
                                                                    <f:ajax event="keyup" execute="@this year month" render="calNewPtDob" listener="#{opdPreBillController.dateChangeListen()}" />
                                                                </p:inputText>
                                                                <p:calendar  value="#{opdPreBillController.newPatient.person.dob}" 
                                                                             id="calNewPtDob"  navigator="true" pattern="dd/MM/yyyy" 
                                                                             style="width: 100px!important;"
                                                                             styleClass="shortinput">
                                                                    <f:ajax event="dateSelect" />
                                                                </p:calendar>
                                                            </h:panelGrid>
                                                        </td>
                                                    </tr>

                                                    <tr>
                                                        <td >
                                                            <h:outputLabel value="Phone,Area &amp; Nic"/>
                                                        </td>
                                                        <td> : </td>
                                                        <td >
                                                            <p:inputMask mask="999-9999999" id="txtNewPtPhone" 
                                                                         autocomplete="off" maxlength="11" 
                                                                         value="#{opdPreBillController.newPatient.person.phone}"
                                                                         style="width: 100px;">
                                                            </p:inputMask>
                                                        </td>
                                                        <td  >
                                                            <p:autoComplete id="acNewPtArea" converter="areaCon" 
                                                                            completeMethod="#{areaController.completeArea}" 
                                                                            var="pta" itemLabel="#{pta.name}" styleClass="shortinput"
                                                                            itemValue="#{pta}" forceSelection="true" 
                                                                            value="#{opdPreBillController.newPatient.person.area}" ></p:autoComplete>
                                                            <p:inputMask mask="999999999V" value="#{opdPreBillController.newPatient.person.nic}" />
                                                        </td>

                                                    </tr>
                                                </table>

                                                <p:watermark value="YEAR" for="year" />
                                                <p:watermark value="MONTH" for="month" />
                                                <p:watermark value="DAYS" for="day" />
                                                <p:watermark for="calNewPtDob" value="Birthday" ></p:watermark>

                                            </p:tab>

                                            <p:tab id="tabSearchPt" title="Search Patient">

                                                <h:panelGrid columns="1" >

                                                    <p:autoComplete styleClass="mediuminput"
                                                                    disabled="#{opdPreBillController.fromOpdEncounter}"
                                                                    widgetVar="aPt" id="acPt" forceSelection="true" 
                                                                    value="#{opdPreBillController.searchedPatient}" 
                                                                    completeMethod="#{patientController.completePatientByNameOrCode}" 
                                                                    var="apt" itemLabel="#{apt.person.name}" 
                                                                    itemValue="#{apt}" size="30"  style="width: 400px;" >


                                                        <p:column headerText="Name">
                                                            <h:outputLabel value="#{apt.person.nameWithTitle}" />
                                                        </p:column>

                                                        <p:column headerText="Age">
                                                            <h:outputLabel value="#{apt.age}" />
                                                        </p:column>
                                                        <p:column headerText="Code">
                                                            <h:outputLabel value="#{apt.code}" />
                                                        </p:column>
                                                        <p:column headerText="Sex">
                                                            <h:outputLabel value="#{apt.person.sex}" />
                                                        </p:column>
                                                        <p:column headerText="Address">
                                                            <h:outputLabel value="#{apt.person.address}" />
                                                        </p:column>
                                                        <p:column headerText="Date of Birth">
                                                            <h:outputLabel value="#{apt.person.dob}" >
                                                                <f:convertDateTime pattern="dd MMMM yyyy"/>
                                                            </h:outputLabel>
                                                        </p:column>
                                                        <f:ajax event="itemSelect" execute=":#{p:component('cmbPs')} @this" 
                                                                render="panSearch :#{p:component('tblBillItem')} :#{p:component('pBillDetails')}" 
                                                                listener="#{opdPreBillController.calTotals()}" />
                                                    </p:autoComplete>   

                                                    <h:panelGroup id="panSearch">
                                                        <pat:searchPatientDetail patient="#{opdPreBillController.searchedPatient}"  />
                                                    </h:panelGroup>

                                                    <div style="padding: 2px; margin: 2px; border: 1px solid;">
                                                        <p:outputLabel value="#{pharmacySaleController.opdEncounterComments}" ></p:outputLabel>
                                                    </div>

                                                </h:panelGrid>


                                            </p:tab>

                                        </p:tabView>

                                    </h:panelGroup>
                                </p:panel>

                                <h:panelGroup id="panelIx" >


                                    <p:panel id='pIxAdd' header="Items / Services" style="min-height: 350px;"  >
                                        <p:focus  context="acIx"/>
                                        <p:autoComplete widgetVar="aIx" id="acIx" forceSelection="true"
                                                        value="#{opdPreBillController.currentBillItem.item}" 
                                                        completeMethod="#{itemController.completeOpdItemsByNamesAndCode}"
                                                        var="ix" itemLabel="#{ix.name}" itemValue="#{ix}"
                                                        size="30"  style="width: 400px;" >
                                            <p:column>
                                                #{ix.name}
                                            </p:column>
                                            <p:column>
                                                #{ix.fullName}
                                            </p:column>
                                            <p:column>
                                                #{ix.department.name}
                                            </p:column>
                                            <p:column>
                                                #{ix.total}
                                            </p:column>
                                            <p:ajax event="itemSelect"  listener="#{opdPreBillController.fillBillSessions}" process="acIx" update="tblSs" ></p:ajax>
                                        </p:autoComplete>
                                        <h:commandButton id="btnAddIx" value="Add" action="#{opdPreBillController.addToBill()}"  style="width: 75px;"  >
                                            <f:ajax execute="acIx btnAddIx :#{p:component('cmbPs')} :#{p:component('pay')} panelBillItems" render="focusIx tblBillItem  :#{p:component('pBillDetails')}  pIxAdd" />
                                        </h:commandButton>
                                        <p:defaultCommand target="btnAddIx" />
                                        <p:panel header="Session"  >
                                            <p:calendar id="calS" mode="inline" value="#{opdPreBillController.sessionDate}" pattern="dd MMMM yyyy" >
                                                <f:ajax event="dateSelect" execute="calS" render="tblSs :#{p:component('lblTemS')}" />
                                            </p:calendar>

                                            <p:dataTable id="tblSs" value="#{opdPreBillController.billSessions}" var="bs" emptyMessage="No Numbers Yet">
                                                <f:facet name="header">
                                                    <h:outputLabel value="#{opdPreBillController.lastBillItem.item.name}" />

                                                    <h:outputLabel id="lblTemS" value="#{opdPreBillController.sessionDate}" >
                                                        <f:convertDateTime pattern="dd MMM yyyy" ></f:convertDateTime>
                                                    </h:outputLabel>



                                                </f:facet>
                                                <p:column headerText="No.">
                                                    <h:outputLabel value="#{bs.serialNo}" />
                                                </p:column>
                                                <p:column headerText="Client">
                                                    <h:outputLabel value="#{bs.billItem.bill.patient.person.nameWithTitle}" />
                                                </p:column>
                                            </p:dataTable>
                                        </p:panel>
                                    </p:panel>



                                </h:panelGroup>

                            </h:panelGrid>


                            <h:panelGrid columns="1" >

                                <p:dialog id="panDoc" header="Add New Doctor" widgetVar="dlg" resizable="false">  
                                    <h:panelGrid columns="2" style="margin-bottom:10px">  
                                        <h:outputText id="lblNameD" value="Name" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtNameD"  value="#{doctorController.current.person.name}"  ></h:inputText>
                                        <h:outputText id="lblPhoneD" value="Phone" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtPhoneD" value="#{doctorController.current.person.phone}"  ></h:inputText>
                                        <h:outputText id="lblFaxD" value="Fax" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtFaxD" value="#{doctorController.current.person.fax}"  ></h:inputText>
                                        <h:outputText id="lblMobileD" value="Mobile" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtMobileD" value="#{doctorController.current.person.mobile}"  ></h:inputText>
                                        <h:outputText id="lblAddressD" value="Address" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtAddressD" value="#{doctorController.current.person.address}"  ></h:inputText>
                                        <h:outputText value="Speciality" ></h:outputText>                                    
                                        <h:selectOneListbox id="cmbSpecialityD" size="1" value="#{doctorController.current.speciality}" >
                                            <f:selectItem itemLabel="Please select a speciality"/>
                                            <f:selectItems value="#{specialityController.items}" var="cat" itemLabel="#{cat.name}" itemValue="#{cat}" />
                                        </h:selectOneListbox>
                                        <h:outputText id="lblRegD" value="Registration" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtRegD" value="#{doctorController.current.registration}"  ></h:inputText>                 
                                        <h:outputText id="lblQuaD" value="Qualification" ></h:outputText>
                                        <h:inputText autocomplete="off" id="txtQuaD" value="#{doctorController.current.qualification}"  ></h:inputText>   

                                        <p:commandButton id="btnDocSave" value="Add New" process="btnDocSave panDoc" update="panDoc :#{p:component('cmbDoc')}" actionListener="#{doctorController.saveSelected()}" styleClass="buttons" oncomplete="dlg.hide();">
                                        </p:commandButton>

                                    </h:panelGrid>  

                                </p:dialog>  


                                <h:panelGroup id="panelBillReferrals" >
                                    <p:tabView >
                                        <p:tab title="Refering Doctor">
                                            <p:autoComplete forceSelection="true" id="cmbDoc" value="#{opdPreBillController.referredBy}" completeMethod="#{doctorController.completeDoctor}" var="ix" itemLabel="#{ix.person.name}" itemValue="#{ix}" size="30"  style="width: 400px;">
                                            </p:autoComplete>
                                            <p:commandButton id="btnAddNewDoc" type="button" value="Add New Doctor" onclick="dlg.show();" actionListener="#{doctorController.prepareAdd}" process="btnAddNewDoc" update="#{p:component('panDoc')}" />  

                                        </p:tab>
                                        <p:tab title="Credit" >
                                            <p:panelGrid columns="2">
                                                <p:outputLabel value="Credit Company"></p:outputLabel>
                                                <p:autoComplete id="creditCompany" 
                                                                forceSelection="true"
                                                                value="#{opdPreBillController.creditCompany}"  
                                                                completeMethod="#{creditCompanyController.completeCredit}" var="ix" 
                                                                itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 300px;">

                                                    <f:ajax  event="itemSelect" listener="#{opdPreBillController.calTotals()}"
                                                             execute="@this" 
                                                             render=":#{p:component('panelBillTotals')}  :#{p:component('tblRequests')} :#{p:component('tblBillItem')}" />
                                                </p:autoComplete> 


                                                <p:outputLabel value="Staff Mamber"></p:outputLabel>
                                                <p:autoComplete  style="width: 300px;" 
                                                                 forceSelection="true" 
                                                                 value="#{opdPreBillController.toStaff}" 
                                                                 id="creditStaff"
                                                                 completeMethod="#{staffController.completeStaff}" 
                                                                 var="mys" 
                                                                 itemLabel="#{mys.person.nameWithTitle}" 
                                                                 itemValue="#{mys}"
                                                                 converter="stfcon" >
                                                    <p:column headerText="Name" >
                                                        <h:outputLabel value="#{mys.person.nameWithTitle}" ></h:outputLabel>
                                                    </p:column>
                                                    <p:column headerText="Annual Entitlement">
                                                        <h:outputLabel value="#{mys.annualWelfareQualified}" >
                                                            <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                        </h:outputLabel>
                                                    </p:column>
                                                    <p:column  headerText="Annual Utilized Value">
                                                        <h:outputLabel value="#{mys.annualWelfareUtilized}" >
                                                            <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                        </h:outputLabel>
                                                    </p:column>

                                                    <p:ajax process="@this" 
                                                            update="creditCompany :#{p:component('panelBillTotals')}  :#{p:component('tblRequests')} :#{p:component('tblBillItem')}"
                                                            event="itemSelect"  listener="#{opdPreBillController.calTotals()}" />

                                                </p:autoComplete>

                                                <p:watermark for="creditStaff" value="Type at least 3 charactors of Staff member." ></p:watermark>
                                            </p:panelGrid>
                                        </p:tab>  



                                        <p:tab title="Staff">
                                            <p:autoComplete forceSelection="true" converter="stfcon" value="#{opdPreBillController.staff}" completeMethod="#{staffController.completeStaff}" var="ix2" itemLabel="#{ix2.person.name}" itemValue="#{ix2}" size="30"  style="width: 300px;">
                                            </p:autoComplete>
                                        </p:tab>
                                        <p:tab title="Referrals">
                                            <p:panelGrid columns="2">
                                                <p:outputLabel value="Refferal Institution"></p:outputLabel>
                                                <p:autoComplete forceSelection="true" id="cmdIns" 
                                                                value="#{opdPreBillController.referredByInstitution}" 
                                                                completeMethod="#{institutionController.completeIns}" var="refi" 
                                                                itemLabel="#{refi.name}" itemValue="#{refi}" converter="institutionConverter">
                                                    <p:column headerText="Name">
                                                        #{refi.name}
                                                    </p:column>
                                                    <p:column headerText="Code">
                                                        #{refi.institutionCode}
                                                    </p:column>
                                                    <p:column headerText="Institution Type">
                                                        #{refi.institutionType}
                                                    </p:column>
                                                </p:autoComplete>
                                                <p:outputLabel value="Referral Number"></p:outputLabel>
                                                <p:inputText value="#{opdPreBillController.referralId}" style="width: 400px"></p:inputText>
                                            </p:panelGrid>
                                        </p:tab>
                                    </p:tabView>
                                </h:panelGroup>



                                <h:panelGroup id="panelBillItems" >


                                    <p:tabView id="tblBillItem" >





                                        <p:tab id="tabBillItems" title="Bill Items" >
                                            <p:dataTable id="tblRequests" rowIndexVar="rowIndex" value="#{opdPreBillController.lstBillEntries}" var="bi" >

                                                <p:column>
                                                    <f:facet name="header">No</f:facet>
                                                        #{rowIndex+1}
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Item</f:facet>
                                                        #{bi.billItem.item.name}
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Fee</f:facet>
                                                    <h:outputLabel value="#{bi.billItem.netValue}">
                                                        <f:convertNumber pattern="#,##0.00" />
                                                    </h:outputLabel>
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Department</f:facet>
                                                        #{bi.billItem.item.department.name}
                                                </p:column>

                                                <p:column>
                                                    <h:commandButton id="btnRemove" value="X" action="#{opdPreBillController.removeBillItem}" >
                                                        <f:setPropertyActionListener  value="#{rowIndex}" target="#{opdPreBillController.index}" />
                                                        <p:ajax  process="btnRemove" update=":#{p:component('tblBillItem')} :#{p:component('pBillDetails')}" />
                                                    </h:commandButton>
                                                </p:column>
                                            </p:dataTable>
                                        </p:tab>
                                        <p:tab id="tabBillIx" title="Tests" >
                                            <p:dataTable rowIndexVar="rowIndex" value="#{opdPreBillController.lstBillComponents}" var="bix" >
                                                <p:column>
                                                    <f:facet name="header">No</f:facet>
                                                        #{rowIndex+1}
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Name</f:facet>
                                                        #{bix.item.name}
                                                </p:column>

                                            </p:dataTable>
                                        </p:tab>

                                        <p:tab id="tabBillFee" title="Fees" >
                                            <p:dataTable rowIndexVar="rowIndex" value="#{opdPreBillController.lstBillFees}" var="bif" >
                                                <p:column>
                                                    <f:facet name="header">Item Name</f:facet>
                                                    <h:outputLabel value="#{bif.billItem.item.name}" />
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Fee</f:facet>
                                                    <h:inputText autocomplete="off"  
                                                                 id="txtFeeVal"
                                                                 value="#{bif.feeGrossValue}" disabled="#{!bif.billItem.item.userChangable}" >
                                                        <f:convertNumber pattern="#,##0.00" />
                                                        <f:ajax event="keyup" execute="@this" 
                                                                render=":#{p:component('tblRequests')}  :#{p:component('pBillDetails')}"
                                                                listener="#{opdPreBillController.feeChangeListener(bif)}" />
                                                    </h:inputText>
                                                </p:column>
                                                <p:column>
                                                    <p:commandButton ajax="false" value="Update" action="#{opdPreBillController.feeChangeListener(bif)}" />
                                                </p:column>
                                                <p:column>
                                                    <f:facet name="header">Fee Name</f:facet>
                                                    <h:outputLabel value="#{bif.fee.name}" rendered="#{bif.fee !=null}" ></h:outputLabel>
                                                </p:column>



                                                <p:column>
                                                    <f:facet name="header">Speciality</f:facet>
                                                    <h:outputLabel value="#{bif.fee.speciality.name}" rendered="#{bif.fee !=null and bif.fee.speciality!=null}" ></h:outputLabel>
                                                </p:column>

                                                <p:column>
                                                    <f:facet name="header">Payee</f:facet>                                                
                                                    <p:selectOneMenu value="#{bif.staff}" rendered="#{bif.fee.speciality!=null}" >
                                                        <f:selectItem itemLabel="Select Staff" />
                                                        <f:selectItems  value="#{staffController.getSpecialityStaff(bif.fee.speciality)}" var="bifs" itemLabel="#{bifs.person.name}" itemValue="#{bifs}" />
                                                    </p:selectOneMenu>

                                                </p:column>
                                            </p:dataTable>
                                        </p:tab>
                                    </p:tabView>
                                </h:panelGroup>


                                <h:panelGroup>
                                    <h:panelGroup id="panelBillTotals" >
                                        <p:panel header="Bill Details" id="pBillDetails"  >
                                            <p:panelGrid columns="2" columnClasses="numberCol, textCol"  >
                                                <h:outputLabel value="Total" ></h:outputLabel >
                                                <h:outputLabel id="tot" value="#{opdPreBillController.total}" >
                                                    <f:convertNumber pattern="#,##0.00" />
                                                </h:outputLabel>
                                                <h:outputLabel value="Discount" ></h:outputLabel>
                                                <h:outputLabel id="dis" value="#{opdPreBillController.discount}" >
                                                    <f:convertNumber pattern="#,##0.00" />
                                                </h:outputLabel>
                                                <h:outputLabel value="Net Total" ></h:outputLabel>
                                                <h:outputLabel id="netTotal" value="#{opdPreBillController.netTotal}" >
                                                    <f:convertNumber pattern="#,##0.00" />
                                                </h:outputLabel>
                                            </p:panelGrid>

                                        </p:panel>
                                    </h:panelGroup>

                                </h:panelGroup>


                            </h:panelGrid>


                        </h:panelGrid>
                    </p:panel>
                </h:panelGroup>

                <h:panelGroup rendered="#{opdPreBillController.printPreview}" >



                    <h:panelGrid>

                        <h:panelGrid columns="2" styleClass="nonPrintBlock">
                            <p:commandButton value="Print" ajax="false" action="#"  >
                                <p:printer target="gpPosBill" ></p:printer>
                            </p:commandButton>

                            <p:commandButton value="New Bill" ajax="false" action="#{opdPreBillController.prepareNewBill()}" >
                            </p:commandButton>
                        </h:panelGrid>

                        <h:panelGroup id="gpPosBill">
                            <div>
                                <bi:posOpdBillPre bill="#{opdPreBillController.bills.get(0)}" duplicate="false"/>                        
                            </div>
                        </h:panelGroup>

                    </h:panelGrid>



                </h:panelGroup>

            </h:form>

        </h:panelGroup>
    </ui:define>
</ui:composition>
